
var path="http://localhost:8080/ddln-auth";

$(function(){ 
    var userToken= $.cookie('ddln-admin-id');
    if(userToken==null||userToken==""){
		userToken="89898989";
	} 
	$("#submitS").click(function(){   
		var userName=$("#userName").val();
		var pwd=$("#pwd").val();
		alert(userName);
		$.ajax({ 
			type:"POST",
			url:path+"/auth/login/deleteUserByToken", 
			data:{'userToken':userToken}, 
			dataType:"json",
			success:function(data){   
			},
			error:function(data){  
				//alert("对不起，删除失败");
				
			}
		});
	    $.ajax({ 
			type:"POST",
			url:path+"/auth/login/loginAdmin", 
			data:{"userName":userName,"passWord":pwd},      
			dataType:"json",
			success:function(data){  
				if(data.success=="true"){ 
					//把token 用户标识ID写入cookie
					$.cookie('ddln-admin-id', data.data, { expires: 7, path: '/' });  
					location.href="admin-index.html" 	 
				}else{
					alert("用户名或密码错误");
				}
			   
			    
			},
			error:function(data){ 
				//alert("对不起，加载失败");
			}
		});
	});
});

